package sms;

import java.time.LocalDate;
import java.util.Objects;

public class Student {
    /*学生学号*/
    private Integer studentId;
    /*学生姓名*/
    private String name;


    /*语文成绩*/
    private Integer chineseScore;

    /*数学成绩*/
    private Integer mathScore;

    /*学生入学时间*/
    private LocalDate enrollmentDates;

    /*学生邮箱*/
    private String email;


    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Student(Integer studentId, String name, Integer chineseScore, Integer mathScore, LocalDate enrollmentDates, String email) {
        this(studentId, name, chineseScore, mathScore, enrollmentDates);
        this.email = email;
    }

    public Student(Integer studentId, String name, Integer chineseScore, Integer mathScore, LocalDate enrollmentDates) {
        this.studentId = studentId;
        this.name = name;
        this.chineseScore = chineseScore;
        this.mathScore = mathScore;
        this.enrollmentDates = enrollmentDates;
    }

    public Student(Integer studentId, String name, Integer chineseScore, Integer mathScore) {
        this(studentId, name, chineseScore, mathScore, LocalDate.now());//入学日期默认为当前年月日
    }

    public LocalDate getEnrollmentDates() {
        return enrollmentDates;
    }

    public void setEnrollmentDates(LocalDate enrollmentDates) {
        this.enrollmentDates = enrollmentDates;
    }

    public int getStudentId() {
        return studentId;
    }

    public void setStudentId(int studentId) {
        this.studentId = studentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getChineseScore() {
        return chineseScore;
    }

    public void setChineseScore(Integer chineseScore) {
        this.chineseScore = chineseScore;
    }

    public int getMathScore() {
        return mathScore;
    }

    public void setMathScore(Integer mathScore) {
        this.mathScore = mathScore;
    }


    /*求学生的总成绩*/
    public Integer getTotalScore(){
        return chineseScore + mathScore;
    }

    /*展示学生的信息使用该方法:拼接所有的学生属性*/
    public String toString() {
        return studentId + " " + name + " " + chineseScore + " " + mathScore
                + " " +email+" "+ enrollmentDates + " " + getTotalScore();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Student student)) return false;

        return Objects.equals(name, student.name);
    }
}
